/**
 * NoticeMgr.java
 * @author GorillaFunch
 * @created 2013.01.16
 */
package kr.ac.kongju.gedl.code.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import kr.ac.kongju.gedl.code.dao.CodeDAO;
import kr.ac.kongju.gedl.code.service.CodeService;
import kr.ac.kongju.gedl.code.vo.CodeInfoVO;
import kr.ac.kongju.gedl.common.util.ListResultVO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import egovframework.rte.fdl.cmmn.AbstractServiceImpl;
import egovframework.rte.fdl.property.EgovPropertyService;

@Service("codeService")
public class CodeServiceImpl extends AbstractServiceImpl implements CodeService {
	// Log
	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	/** EgovPropertyService */
    @Resource(name = "propertiesService")
    protected EgovPropertyService propertiesService;
    
    @Resource(name="codeDAO")
	private CodeDAO codeDAO;
    
    
    @Override
	public String registerCodeInfo(CodeInfoVO codeInfo) throws Exception{
		// TODO Auto-generated method stub
		return codeDAO.registerCodeInfo(codeInfo);
	}	
	
    /* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.code.service.impl.CodeService#retrieveCodeInfo(kr.ac.kongju.gedl.code.vo.CodeInfoVO)
	 */
	@Override
	public CodeInfoVO retrieveCodeInfo(CodeInfoVO codeInfo){
		try {
			codeInfo = codeDAO.retrieveCodeInfo(codeInfo);
		} catch (Exception e) {
			logger.error("codeId:{} Message:{}", codeInfo.getCodeId(), e.toString());
		} 
		return codeInfo;
	}
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.code.service.impl.CodeService#retrieveListCountCodeInfo(com.ssc.common.service.SearchVO)
	 */
	@Override
	public int retrieveListCountCodeInfo(CodeInfoVO searchCondition) {
		return codeDAO.retrieveListCountCodeInfo(searchCondition);	
	}	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.code.service.impl.CodeService#retrieveListCodeInfo(com.ssc.common.service.SearchVO)
	 */
	@Override
	public ListResultVO<CodeInfoVO> retrieveListCodeInfo(CodeInfoVO searchCondition) {
		ListResultVO<CodeInfoVO> listResult = new ListResultVO<CodeInfoVO>();
		List<CodeInfoVO> list = new ArrayList<CodeInfoVO>();
		try {
			int count = codeDAO.retrieveListCountCodeInfo(searchCondition);
			if(count > 0){
				list = codeDAO.retrieveListCodeInfo(searchCondition);
				listResult = new ListResultVO<CodeInfoVO>(count, list);
			}
			logger.info("count:{} list.size:{}", count, list.size());
		} catch (Exception e) {
			logger.error("cause:{}", e.toString());
		} 	
		
		return listResult;	
	}

	
}
